package top.jsjkxyjs.blackbox.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Msg<T> {
	//状态码 200：成功 400：失败
	private int code;
	//提示信息
	private String msg;
	private T data;
	private String href;
	private int count;

	public static Msg success() {
		Msg success = new Msg();
		success.setCode(200);
		success.setMsg("处理成功");
		return success;
	}

	public static Msg success(String tips) {
		Msg success = new Msg();
		success.setCode(200);
		success.setMsg(tips);
		return success;
	}

	public static Msg success(Object data, int count) {
		Msg success = new Msg();
		success.setCode(0);
		success.setData(data);
		success.setCount(count);
		return success;
	}

	public static Msg fail() {
		Msg fail = new Msg();
		fail.setCode(400);
		fail.setMsg("处理失败");
		return fail;
	}

	public static Msg tips(String tip, int code) {
		Msg tips = new Msg();
		tips.setCode(code);
		tips.setMsg("[警告]" + tip);
		return tips;
	}
}
